package com.xingkeduo.util.pojo.enums;

import com.xingkeduo.util.pojo.base.BaseEnum;

/**
 * @Description:
 * @Author:gaozifeng
 * @Date 2019/3/21 21:55
 **/
public enum BankEnums implements BaseEnum {
    ZHAOSHANG(1, "中国招商银行"),
    GONGSHANG(2, "中国工商银行"),
    NONGYE(3, "中国农业银行"),
    JIANSHE(4, "中国建设银行"),
    ZHONGGUO(5, "中国银行"),
    YOUZHENG(6, "邮政储蓄银行"),
    JIAOTONG(7, "交通银行");

    private int value;
    private String desc;

    private BankEnums(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static boolean validValue(String value) {
        int value_int = Integer.parseInt(value);
        return validValue(value_int);
    }

    public static boolean validValue(int value) {
        BankEnums[] banks = values();

        for (int i = 0; i < banks.length; ++i) {
            if (banks[i].getValue() == value) {
                return true;
            }
        }

        return false;
    }

    public static BankEnums getBankValue(String value) {
        int value_int = Integer.parseInt(value);
        return getBankValue(value_int);
    }

    public static BankEnums getBankValue(int value) {
        BankEnums[] enums = values();

        for (int i = 0; i < enums.length; ++i) {
            if (enums[i].getValue() == value) {
                return enums[i];
            }
        }

        return null;
    }

    @Override
    public int getValue() {
        return this.value;
    }

    public String getDesc() {
        return this.desc;
    }
}
